package com.IOFileTest;

import org.junit.Test;

import java.io.FileReader;
import java.io.IOException;

public class FileReader_ {
    public static void main(String[] args) {

    }
    @Test
    public void readFile01(){
        String filePath = "d:\\story.txt";
        FileReader fileReader = null;
        int data = 0;
        try{
            fileReader = new FileReader(filePath);
            while ((data = fileReader.read()) != -1){
                System.out.print((char) data);
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    @Test
    public void readFile02(){
        String filePath = "d:\\story.txt";
        FileReader fileReader = null;
        int data = 0;
        char[] chars = new char[8];
        try{
            fileReader = new FileReader(filePath);
            while ((data = fileReader.read(chars)) != -1){

                System.out.print(new String(chars,0,data));
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
